﻿using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using Nop.Web.Areas.App.Attributes;
using Nop.Web.Areas.App.Models;
using Nop.Web.Framework;
using Nop.Web.Framework.Controllers;
using Nop.Web.Framework.Mvc.Filters;
using Nop.Web.Framework.Security;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;


namespace Nop.Web.Areas.App.Controllers
{
    [Area(AreaNames.App)]
    [HttpsRequirement(SslRequirement.NoMatter)]
    [WwwRequirement]
    [CheckAccessPublicStore]
    [CheckAccessClosedStore]
    [CheckLanguageSeoCode]
    [CheckDiscountCoupon]
    [CheckAffiliate]
    [PublishModelEvents]
    [SignOutFromExternalAuthentication]
    [ValidatePassword]
    [SaveIpAddress]
    [SaveLastActivity]
    [UserCenterAttribute]
    public class BaseAppController : Controller
    {
              

        public JsonSerializerSettings SerializerSettings { get; set; } = new JsonSerializerSettings()
        {
            DateFormatString = "yyyy-MM-dd HH:mm:ss",
            ContractResolver = new CamelCasePropertyNamesContractResolver()
        };



        protected virtual JsonResult InvokeHttp404()
        {

            return Json(new AppResult
            {
                Code = 404,
                Message = "数据未发现"
            });
        }

        protected virtual JsonResult InvokeHttp401()
        {

            return Json(new AppResult
            {
                Code = 401,
                Message = "无权限访问"
            });
        }

        public override JsonResult Json(object data)
        {
            return base.Json(data, SerializerSettings);
        }
    }
}
